﻿package lobby
{
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import lobby.exchangeddata.HashTable;
	
	/**
	 * ...
	 * @author ...
	 */
	public class LobbyMenuPanel extends MovieClip
	{
		public var btnChangePassword:SimpleButton;
		public var btnDeposit:SimpleButton;
		public var btnwithdraw:SimpleButton;
		public var btnRecords:SimpleButton;
		public var btnMemberRec:SimpleButton;
		public var btnGameRule:SimpleButton;
		public var btnSupport:SimpleButton;
		public var btnProfile:SimpleButton;
		
		public var txtMNinfoTf:TextField;
		public var txtMNdepositTf:TextField;
		public var txtMNwidthDrawTf:TextField;
		public var txtMNbetstatusTf:TextField;
		public var txtMNgameHisTf:TextField;
		public var txtMNruleTf:TextField;
		public var txtMNhotlineTf:TextField;
		public var txtMNprofileTf:TextField;
		
		private var arrayLableBtn:Array;
		private var arrayBtn:Array;
		private var overColor:Number = 0xFFCC00;
		private var outColor:Number = 0xFFFFFF;
		
		public function LobbyMenuPanel()
		{
			arrayLableBtn = new Array(txtMNinfoTf, txtMNdepositTf, txtMNwidthDrawTf, txtMNbetstatusTf, txtMNgameHisTf, txtMNruleTf, txtMNhotlineTf, txtMNprofileTf);
			arrayBtn = new Array(btnChangePassword, btnDeposit, btnwithdraw, btnRecords, btnMemberRec, btnGameRule, btnSupport, btnProfile);
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++)
			{
				arrayBtn[i].addEventListener(MouseEvent.CLICK, hdlBtnClick);
				arrayBtn[i].addEventListener(MouseEvent.ROLL_OVER, hdlBtnRollOver);
				arrayBtn[i].addEventListener(MouseEvent.ROLL_OUT, hdlBtnRollOut);
				arrayLableBtn[i].mouseEnabled = false;
			}
		
		}
		
		/**
		 * @author Bamboo
		 * @param	e
		 */
		private function hdlBtnClick(e:MouseEvent):void
		{
			trace("anem:" + e.currentTarget.name);
			sendInfoMainGame(e.currentTarget.name);
		
		}
		
		/**
		 * @author	Bamboo
		 * @param	e
		 */
		private function hdlBtnRollOver(e:MouseEvent):void
		{
			
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++)
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = overColor;
					break;
				}
			}
		}
		
		/**
		 * @author	Bamboo
		 * @param	e
		 */
		private function hdlBtnRollOut(e:MouseEvent):void
		{
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++)
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = outColor;
					break;
				}
			}
		}
		
		/**
		 * @author Bamboo
		 * @param	e
		 */
		public function sendInfoMainGame(nameObj:String):void
		{
			trace("ok");
			MovieClip(parent).receiverInfoFromMenu(nameObj);
		
		}
		
		public function initText(hashTableInfo:HashTable):void
		{
			
			this.txtMNinfoTf.text = hashTableInfo.lookupString("MNAccountInfo");
			this.txtMNdepositTf.text = hashTableInfo.lookupString("MNDeposit");
			this.txtMNwidthDrawTf.text = hashTableInfo.lookupString("MNWithdraw");
			this.txtMNbetstatusTf.text = hashTableInfo.lookupString("MNbetstatus");
			this.txtMNgameHisTf.text = hashTableInfo.lookupString("MNgamehistory");
			this.txtMNruleTf.text = hashTableInfo.lookupString("MNgamerule");
			this.txtMNhotlineTf.text = hashTableInfo.lookupString("MNhotline");
			this.txtMNprofileTf.text = hashTableInfo.lookupString("MNMyProfile");
		
		}
	
	}

}